'use strict';

module.exports = app => {
  const { STRING, BIGINT, INTEGER, DATE, BOOLEAN } = app.Sequelize;

  return app.model.define('SystemUser2', {
    id: {
      type: BIGINT,
      primaryKey: true,
      autoIncrement: true,
      comment: '用户ID'
    },
    code: {
      type: STRING(50),
      allowNull: false,
      defaultValue: '',
      comment: '用户编号'
    },
    username: {
      type: STRING(30),
      allowNull: false,
      defaultValue: '',
      comment: '用户账号'
    },
    password: {
      type: STRING(100),
      allowNull: false,
      defaultValue: '',
      comment: '密码'
    },
    employeeNo: {
      type: STRING(50),
      allowNull: false,
      defaultValue: '',
      field: 'employee_no',
      comment: '工号'
    },
    nickname: {
      type: STRING(30),
      allowNull: false,
      defaultValue: '',
      comment: '用户昵称'
    },
    loginType: {
      type: STRING(20),
      allowNull: false,
      defaultValue: '',
      field: 'login_type',
      comment: '登录方式 PASSWORD 密码登录'
    },
    shareFlag: {
      type: INTEGER,
      allowNull: false,
      defaultValue: 0,
      field: 'share_flag',
      comment: '是否可查看其他门店顾客信息 0 否 1 是'
    },
    logisticsCostFlag: {
      type: INTEGER,
      allowNull: false,
      field: 'logistics_cost_flag',
      comment: '物流成本价可见 0 否 1是'
    },
    governanceRole: {
      type: STRING(50),
      allowNull: false,
      field: 'governance_role',
      comment: '管辖角色 beautician 美容师'
    },
    remark: {
      type: STRING(500),
      allowNull: true,
      comment: '备注'
    },
    deptId: {
      type: BIGINT,
      allowNull: true,
      field: 'dept_id',
      comment: '部门ID'
    },
    postIds: {
      type: STRING(255),
      allowNull: true,
      field: 'post_ids',
      comment: '岗位编号数组'
    },
    email: {
      type: STRING(50),
      allowNull: true,
      defaultValue: '',
      comment: '用户邮箱'
    },
    mobile: {
      type: STRING(11),
      allowNull: true,
      defaultValue: '',
      comment: '手机号码'
    },
    sex: {
      type: INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: '用户性别'
    },
    avatar: {
      type: STRING(512),
      allowNull: true,
      defaultValue: '',
      comment: '头像地址'
    },
    status: {
      type: INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: '帐号状态（0正常 1停用）'
    },
    loginIp: {
      type: STRING(50),
      allowNull: true,
      defaultValue: '',
      field: 'login_ip',
      comment: '最后登录IP'
    },
    loginDate: {
      type: DATE,
      allowNull: true,
      field: 'login_date',
      comment: '最后登录时间'
    },
    creator: {
      type: STRING(64),
      allowNull: true,
      defaultValue: '',
      comment: '创建者'
    },
    createTime: {
      type: DATE,
      allowNull: false,
      defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
      field: 'create_time',
      comment: '创建时间'
    },
    updater: {
      type: STRING(64),
      allowNull: true,
      defaultValue: '',
      comment: '更新者'
    },
    updateTime: {
      type: DATE,
      allowNull: false,
      defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
      field: 'update_time',
      comment: '更新时间'
    },
    deleted: {
      type: BOOLEAN,
      allowNull: false,
      defaultValue: false,
      comment: '是否删除'
    }
  }, {
    tableName: 'system_users',
    timestamps: false, // 不使用Sequelize的默认时间戳字段
  });
};
